package com.yuanfeng.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanfeng.business.dto.*;
import com.yuanfeng.business.entity.ShopBaseEntity;
import com.yuanfeng.business.vo.*;
import com.yuanfeng.commoms.dto.goods.CommonShopStateDTO;
import com.yuanfeng.commoms.dto.goods.ShopListQueryDTO;
import com.yuanfeng.commoms.dto.shop.ArticleShopDTO;
import com.yuanfeng.commoms.dto.shop.ShopTreasureGradeUpdateDTO;
import com.yuanfeng.commoms.dto.shop.WebShopListQueryDTO;
import com.yuanfeng.commoms.dto.shop.WebShopListQueryEsDTO;
import com.yuanfeng.commoms.vo.base.BaseSysConfigsVO;
import com.yuanfeng.commoms.vo.goods.GdsListQueryResultVO;
import com.yuanfeng.commoms.vo.order.OrderComplaintsVO;
import com.yuanfeng.commoms.vo.order.WapShopShippingQueryResultVO;
import com.yuanfeng.commoms.vo.shop.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;


/**
 * @author admin
 * @Entity com.yuanfeng.business.entity.MerchantShopBase
 */
@Mapper
public interface ShopBaseMapper extends BaseMapper<ShopBaseEntity> {


    /**
     * es 查询店铺数据
     * @return
     */
    List<ArticleShopDTO> selectAllShop();
    /**
     * 根据店铺id查询店铺信息
     * @param shopId
     * @return
     */
    WebShopListQueryEsDTO selectByShopId2(Integer shopId);


    List<GdsListQueryResultVO> selectByShopId3(@Param("shopId") Integer shopId);

    Integer selectShopSum(@Param("shopId") Integer shopId);
    /**
     * 移动端根据店铺id查询店铺信息
     * @param shopId
     * @return
     */
    ShopListQueryDTO selectByH5ShopId(Integer shopId);

    /**
     * 查询店铺类型
     * @param shopId
     * @return
     */
    Integer checkTheStatus(String shopId);

    /**
     * 查询店铺的发票状态
     * @param paramTmp
     * @return
     */
    InvoiceSwitchEntityVO queryShopInvoiceSwitch(@Param("param") Map<String, Object> paramTmp);

    /**
     * 分页查询店铺
     *
     * @param page
     * @param param
     * @return
     */
    IPage<ShopBaseEntity> queryShopInvoiceSwitchs(Page<ShopBaseEntity> page, @Param("param") ShopBaseListDTO param);

    /**
     * 根据shopid 查询店铺信息
     * @param shopId
     * @return
     */
    GdsShopDetailResultVO queryShopinfoByShopId(Integer shopId);

    /**
     * 通过参数查询
     *
     * @param shopId
     * @return
     */
    ShopIndexVO selectByParam(Integer shopId);

    /**
     * 更新店铺收藏量
     * @param paraMap
     * @return
     */
    Integer updateShopCollect(@Param("param") Map<String, String> paraMap);

    /**
     * 查询店铺信息
     * @param shopId
     * @return
     */
    WapShopShippingQueryResultVO selectByShopId(@Param("shopId")Integer shopId);

    /**
     * 查询供应商店铺信息
     * @param supplyShopId
     * @return
     */
    GdbMerchantShopBaseVO selectSupplierShopByPrimaryKey(Integer supplyShopId);

    /**
     * 获取卖家id卖家名
     * @param shopId
     * @return
     */
    ShopUserMessageResultVO selectUserIdByShopId(@Param("shopId") Integer shopId);

    /**
     * 根据店铺名称查询店铺总数
     * @param shopName
     * @return
     */
    Integer queryShopNameCount(@Param("shopName") String shopName);

    /**
     * 根据店铺名称查询店铺总数
     * @param shopName
     * @return
     */
    Integer queryShopNameJoinCount(@Param("shopName")  String shopName);


    /**
     * 删除店铺经营类目
     * @param param
     */
    void deleteShopBindProduct(@Param("param") ShopClassBindQueryDTO param);

    /**
     * 查询比例
     * @param catId
     * @return
     */
    CommissionRateBeanVO selectCommissionRate(@Param("catId")Integer catId);

    /**
     * 查询在前台显示的类目
     * @param catId
     * @return
     */
    ManageShopCatMenuVO selectByCatId2(@Param("catId") Integer catId);

    /**
     * 添加或者修改类目
     * @param currentCat
     */
    void insertOrUpdateSelective(@Param("currentCat") GdbMerchantClassBindDTO currentCat);

    /**
     * 查询店铺信息
     * @param shopId
     * @return
     */
    WebShopBaseIndexVO selectWebIndex(@Param("shopId")Integer shopId);

    /**
     * 查询商品commonId
     * @param goodsId
     * @return
     */
    Integer selectCommonId(@Param("goodsId")Integer goodsId);

    /**
     * 查询店铺首页商品
     * @param recommendParam
     * @return
     */
    List<GdsListQueryResultVO> selectWebShopIndex(@Param("param")WebIndexRecommendQueryParamVO recommendParam);

    /**
     * 查询商品首页数量
     * @param recommendParam
     * @return
     */
    Integer selectWebShopIndexCount(@Param("param")WebIndexRecommendQueryParamVO recommendParam);

    /**
     * 查询店铺 店招等
     * @param shopId
     * @return
     */
    Map<String, Object> queryByShopIdFind(@Param("shopId")Integer shopId);

    /**
     * 查询店铺信息
     * @param shopId
     * @return
     */
    OperateMessagQueryVO selectOperateMessage(@Param("shopId") Integer shopId);

    /**
     * 判断个人店铺、企业店铺
     * @param shopId
     * @return
     */
    WapShopBaseDetailVO queryQualificationsByShopId(@Param("shopId")Integer shopId);

    /**
     * 根据用户id查询 shopId
     * @param param
     * @return
     */
    Integer queryShopIdByUserId(@Param("param") Map<String, Object> param);

    /**
     * 查询店铺类型
     * @param param
     * @return
     */
    Integer getShopType(@Param("param")Map<String, Object> param);

    /**
     * 查询店铺类型
     * @param shopClass
     * @return
     */
    Integer getShopTypeByClass(@Param("shopClass")Integer shopClass);

    /**
     * 查询是否是自己商品
     * @param param
     * @return
     */
    Integer checkShopSelf(@Param("param")Map<String, Object> param);

    /**
     * 查询是否是自己经销商品
     * @param param
     * @return
     */
    Integer checkSupplySelf(@Param("param")Map<String, Object> param);

    /**
     * 查询店铺状态
     *
     * @param shopId
     * @return
     */
    ShopStatusQueryResultVO selectShopStatus(@Param("shopId") String shopId);

    /**
     * 店铺免额度查询
     * @param shopId
     * @return
     */
    BigInteger selectFreeShipping(@Param("shopId") Integer shopId);

    /**
     * 查询用户id
     * @param userMobile
     * @return
     */
    String queryUserInfoUserId(@Param("userMobile")String userMobile);

    /**
     * 插入店铺数据
     * @param shopbase
     * @return
     */
    Integer insertShopBase(@Param("param")Map<String, Object>  shopbase);

    /**
     * 获取所有三级商品分类id
     * @return
     */
    List<Integer> selectCatId();

    /**
     *
     * @param catId
     * @return
     */
    List<Map<String, Object>> selectCommissionRateList(@Param("catIds")List<Integer> catId);

    /**
     *
     * @param map
     * @return
     */
    Integer insertSellerbase(@Param("param") Map<String, Object> map);

    /**
     * 更新用户密码
     * @param paraMap
     * @return
     */
    Integer forgotPassword(Map<String, Object> paraMap);

    /**
     * 删除店铺以及相关信息
     * @param shopId
     */
    void deleteShopBase(@Param("shopId")Integer shopId);

    void deleteShopJoinBase(@Param("userId")String userId);


    Integer selectShopOrder(@Param("shopId")Integer shopId);

    /**
     * 根据shopId查询shopName
     * @param shopId
     * @return
     */
    String selectShopNameByShopId(Integer shopId);

    /**
     * 查询全部店铺数量
     *
     * @return
     */
    @Select("select count(*) from shop_base gsb where shop_status = 3")
    Integer queryAllShopCount();
//	where shop_status = 3

    /**
     * 查询当天店铺数量
     *
     * @return
     */
    Integer queryTodayShopCount();

    /**
     * 查询本周店铺数量
     *
     * @return
     */
    Integer queryWeekShopCount();

    /**
     * 查询本月店铺数量
     *
     * @return
     */
    Integer queryMonthShopCount();

    /**
     * 查询本年度店铺数量
     *
     * @return
     */
    Integer queryYearShopCount();

    /**
     * 更新店铺免额度
     * @param param
     */
    void updateFreeShipping(@Param("param") ManageShopFreeShippingDTO param);

    /**
     *获取店铺列表
     * @param map
     * @return
     */
    IPage<ShopBaseEntity> selectshop(IPage<ShopBaseEntity> page , @Param("param") Map<String, Object> map);


    SelfShopDetailVO selectSelfShopDetail(@Param("param")Integer shopId);

    void updateShopState(@Param("param") CommonShopStateDTO param);

    void updateGoodsState(@Param("param")CommonShopStateDTO param);

    void updateShopState1(@Param("shopId") Integer shopId);

    void updateSelfShop(@Param("param") SelfShopUpdateDTO param);

    void updateSelfShopJoin(@Param("param") SelfShopUpdateDTO param);

    IPage<SelfShopListQueryVO> selectSelfShopList(IPage<SelfShopListQueryVO> page , @Param("param") ShopBaseListQueryDTO param);

    /**
     * 查询店铺门店
     * @param shopId
     * @return
     */
    ShopGateDTO queryShopGateById2(@Param("shopId") String shopId);

    /**
     * 查询设置店铺
     * @param shopId
     * @return
     */
    ManageSetShopParamQueryDTO selectSetShop(@Param("shopId") String shopId);

    /**
     * 更新设置店铺
     * @param param
     */
    void updateSetShop(@Param("param") ManageSetShopParamAddDTO param);

    /**
     * 更新联系人电话
     * @param param
     */
//    void updateContactsPhone(@Param("param") ManageSetShopParamAddDTO param);

    /**
     * 更新店铺轮播电话
     * @param param
     */
    void updateMobileShopSlide(@Param("param") ManageShopSlideDTO param);

    /**
     * 更新店铺轮播
     * @param param
     */
    void updateShopSlide(@Param("param") ManageShopSlideDTO param);

    /**
     * 查询店铺轮播
     * @param shopId
     * @return
     */
    ManageShopSlideVO selectShopSlide(@Param("shopId") String shopId);

    /**
     * 查询质保金
     * @param shopId
     * @return
     */
    DepositDetailVO selectDeposit(@Param("shopId") String shopId);

    /**
     * 更新质保金
     * @param param
     */
    void updateManageDeposit(@Param("param") DepositDetailDTO param);

    /**
     * 查询退保信息
     * @param shopId
     * @return
     */
    ReturnBondVO selectReturnBond(@Param("shopId") String shopId);

    /**
     * 更新退保信息
     * @param param
     */
    void updateReturnBond(@Param("param") ReturnBondDTO param);

    /**
     * 获取店铺id
     * @param param
     * @return
     */
    Integer getShopId(@Param("param") Map<String, Object> param);

    /**
     * 获取未完成开票的订单数量
     * @param param
     * @return
     */
    Integer getUndealedOrderCount(@Param("param") Map<String, Object> param);

    /**
     * 更新开票功能
     * @param param
     */
    void updateInvoiceSwitch(@Param("param") Map<String, Object> param);


    /**
     * 查询店铺
     *
     * @param param
     * @return
     */
    ShopJoinAptitudeInfoForPlatformDetailVO queryShopJoinAptitudeDetailForPlatform(@Param("param") Map<String, Object> param);


    /**
     * 更新店铺
     *
     * @param param
     */
    void verifyShopMesModify(ShopBusinessModifyVerifyDTO param);


    /**
     * 分页查询店铺
     *
     * @param page
     * @param param
     * @return
     */
    IPage<ShopJoinAptitudeInfoForPlatformVO> queryShopJoinAptitudeListForPlatform(
            IPage<ShopJoinAptitudeInfoForPlatformVO> page, @Param("param") Map<String, Object> param);


    /**
     * 分页查询店铺名称
     *
     * @param page
     * @param param
     * @return
     */
    IPage<ShopNameModifyListVO> selectShopNameModifyList(IPage<ShopNameModifyListVO> page, @Param("param") ShopBaseListDTO param);


    /**
     * 查询店铺集合
     *
     * @param param
     * @return
     */
    List<ShopBaseListExpVO> selectByShopListExp(@Param("param") ShopBaseListDTO param);


    /**
     * 查询店铺集合
     *
     * @param page
     * @param param
     * @return
     */
    IPage<ShopBaseListVO> selectByShopList(IPage<ShopBaseListVO> page, @Param("param") ShopBaseListDTO param);

    /**
     * 更新状态
     *
     * @param param
     */
    void updateVoucherState(@Param("commonParam") Map<String, Object> param);


    /**
     * 更新基础状态
     *
     * @param param
     */
    void updateVoucherBaseState(@Param("commonParam") Map<String, Object> param);


    /**
     * 修改店铺状态
     *
     * @param param
     */
    void updateShopBaseStatus(@Param("param") ShopBaseUpdateDTO param);


    /**
     * 通过店铺id查询
     *
     * @param shopId
     * @return
     */
    ShopBaseVO selectInfoByShopId(Integer shopId);

    /**
     * 修改店铺
     *
     * @param param
     */
    void updateShopBase(@Param("param") PersonMessageInfoDTO param);

    /**
     * 移动端 查询所有店铺
     * @param page
     * @param param
     * @return
     */
    IPage<ShopListQueryResultVO> selectUniappQueryShopList(IPage<ShopListQueryResultVO> page, @Param("param")ShopListQueryDTO param);

    /**
     * 查询店铺 三件在售商品
     * @param record
     * @return
     */
    List<Map<String, Object>> selectUniappQueryShopGoods(@Param("param")ShopListQueryResultVO record);


    void updateShopDecoration(@Param("param") ShopDecorationAddDTO param);

    IPage<ManageShopVideoListVO> selectVideoList(Page<ManageShopVideoListVO> page,@Param("param") ManageShopVideoParamDTO param);



    ShopTreasureGradeVO selectShopTreasureGrade(@Param("shopId") String shopId);


    void updateShopTreasureGrade(@Param("param") ShopTreasureGradeUpdateDTO param);


    List<ShopAllBaseDistrictVO> selectAllDistrict2();


    IPage<WebShopListQueryResultVO> selectShopListFilter(IPage<WebShopListQueryResultVO> page , @Param("param") WebShopListQueryDTO param);


    String selectConfigValue(@Param("configKey")String configKey);


    Integer selectplus();

    /**
     * '查询所有非供应商店铺
     * @param page
     * @param param
     * @return
     */
    IPage<ShopBaseListQueryVO> allRegularStore(IPage<ShopBaseListQueryVO> page, @Param("param")ShopBaseListQueryDTO param);


    int updateByPrimaryConfigKey( @Param("param")Map<String, Object> map);


    BaseSysConfigsVO selectByConfigType(String configKey);


    String queryAccountBalance(@Param("userId") String userId);


    //查询本月罚款金额
    String querymonthFine(@Param("param") Map<String, Object> map);


    //查询未赔付投诉单
    List<OrderComplaintsVO> unpaidcomplaints(@Param("shopId") Integer shopId);


    Integer insertDetail(@Param("param") Map<String, Object> map);


    Integer updateCardMemberDetailPort(Map<String, Object> manageMoney);


    Integer insertConsumeRecordport(Map<String, Object> comRecord);


    Integer updateispay(@Param("id") Integer id);


    boolean insertSysMessage(@Param("messageOrderId") String messageOrderId,@Param("sellerId") String sellerId, @Param("sellerName") String sellerName,
                             @Param("messageType") Integer messageType, @Param("messageTitle") String messageTitle
            , @Param("messageContent") String messageContent,@Param("shopId") String shopId);

    Integer updateshopbase(@Param("param") Map<Object, Object> map);


    IPage<ShopBaseEntity> queryshop(IPage<ShopBaseEntity> page , @Param("param") Map<String, Object> param);


    ShopBaseDTO queryForShopBase(@Param("payId") Integer payId);

    String selectuserphone(@Param("userId") String userId);
}
